package cn.gem.rainbow.biz;

import cn.gem.rainbow.pojo.entity.SysPermission;
import cn.gem.rainbow.pojo.entity.SysRole;
import cn.gem.rainbow.pojo.entity.SysUser;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.Set;

@Service
public class LoginService {

    public SysUser getUserByName(String uName) {
        SysPermission permissions1 = new SysPermission(1, "query");
        SysPermission permissions2 = new SysPermission(2, "add");
        SysPermission permissions3 = new SysPermission(3, "login");
        Set<SysPermission> permissionsSet = new HashSet<>();
        permissionsSet.add(permissions1);
        permissionsSet.add(permissions2);
        permissionsSet.add(permissions3);
        SysRole role = new SysRole(1, "admin", permissionsSet);
        Set<SysRole> roleSet = new HashSet<>();
        roleSet.add(role);
        SysUser user = new SysUser(5, "wsl", "123456", roleSet);

        if (uName.equals(user.getName())){
            return user;
        }

        return null;
    }
}
